package com.xhwl.data.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xhwl.common.pojo.cent.sdata.EnterpriseExtra;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 企业扩展信息表 Mapper 接口
 * </p>
 *
 * @author yf
 * @since 2023-02-14
 */
@Mapper
public interface EnterpriseExtraDao extends BaseMapper<EnterpriseExtra> {

    /**
     * 获取企业附加属性值
     *
     * @param enterpriseId
     * @param attribute
     * @return
     */
    @Select("SELECT CONVERT( trim( '\"' FROM json_extract ( `json`, #{attribute} ) ), CHAR ) " +
            "FROM `sdata_enterprise_extra` " +
            "WHERE `enterprise_id` = #{enterpriseId}")
    String get(@Param("enterpriseId") Integer enterpriseId, @Param("attribute") String attribute);


    /**
     * 通过extra获取企业扩展信息，南飞鸿酆泽数据同步专属，extra为 “nfh-”+"租户号"+"-R/O"
     */
    EnterpriseExtra getEnterpriseIdByExtra(@Param("extra") String extra);

}
